# Maintainer: Evangelos Foutras <evangelos@foutrelis.com>

pkgname=('php-memcached' 'php-legacy-memcached')
pkgver=3.2.0
_commit=d1cb3ae87be5382444322118f87324f4044d13b0
pkgrel=2
pkgdesc="PHP extension for interfacing with memcached via libmemcached library"
arch=('loong64' 'x86_64')
url="https://github.com/php-memcached-dev/php-memcached"
license=('PHP')
depends=('libmemcached')
makedepends=('php' 'php-legacy' 'git')
source=("git+https://github.com/php-memcached-dev/php-memcached.git#commit=$_commit")
sha256sums=('SKIP')

pkgver() {
  cd $pkgbase
  git describe --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}

prepare() {
  cp -a $pkgbase{,-php-legacy}
}

build() {
  cd $pkgbase
  phpize
  ./configure --prefix=/usr
  make

  cd ../$pkgbase-php-legacy
  phpize-legacy
  ./configure --prefix=/usr
  make
}

package_php-memcached() {
  depends+=('php')
  backup=('etc/php/conf.d/memcached.ini')

  cd $pkgbase

  make INSTALL_ROOT="$pkgdir" install
  install -d "$pkgdir/etc/php/conf.d"
  echo ';extension=memcached.so' >"$pkgdir/etc/php/conf.d/memcached.ini"
}

package_php-legacy-memcached() {
  pkgdesc=${pkgdesc/PHP/PHP Legacy}
  depends+=('php-legacy')
  backup=('etc/php-legacy/conf.d/memcached.ini')

  cd $pkgbase-php-legacy

  make INSTALL_ROOT="$pkgdir" install
  install -d "$pkgdir/etc/php-legacy/conf.d"
  echo ';extension=memcached.so' >"$pkgdir/etc/php-legacy/conf.d/memcached.ini"
}

# vim:set ts=2 sw=2 et:
